﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Collections;
using Webchatting.Common;
using Webchatting.Dal;

public partial class server_DropGroup : System.Web.UI.Page
{
    public static ArrayList arrGroupIds = new ArrayList();
    public static ArrayList arrGroupNames = new ArrayList();
    public static ArrayList arrGroupDess = new ArrayList();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnListMyCreatedGroup_Click(object sender, EventArgs e)
    {
        FormsIdentity id = (FormsIdentity)User.Identity;
        OperationGroup Ogroup = new OperationGroup();
        string mygroup = Ogroup.LoadMyGroupDetails(id.Ticket.UserData.Split('@')[0], arrGroupIds, arrGroupNames, arrGroupDess);
        ltlResult.Visible = true;
        ltlText.Visible = true;

        ltlResult.Text = "<b>我创建的群：</b><br/>" + mygroup;
        ltlText.Text = "<b>请选择要操作的群ID：</b>";
        ddlSelectGroup.Visible = true;
        btnDropGroup.Visible = true;
        while (ddlSelectGroup.Items.Count > 0)
        {
            ddlSelectGroup.Items.RemoveAt(0);
        }

        for (int i = 0; i < arrGroupIds.Count; i++)
        {
            ddlSelectGroup.Items.Add(new ListItem((string)arrGroupIds[i], (string)arrGroupIds[i]));
        }

    }
    protected void btnDropGroup_Click(object sender, EventArgs e)
    {
        OperationGroup Ogroup = new OperationGroup();
        int selected = ddlSelectGroup.SelectedIndex;
        try
        {


            Ogroup.DeleteGroupMumAll(arrGroupIds[selected].ToString());
            Ogroup.DropGroup(arrGroupIds[selected].ToString());
            Response.Write("<script>alert('解散群成功!');window.parent.location.href='DropGroup.aspx';</script>");
        }
        catch
        {
            Javascript.GoHistory(-1, "添加失败", Page);
        }
    }
}
